﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Utilidades.basededatos
{
    public partial class frConfigura : Form
    {
        private frConfigura()
        {
            InitializeComponent();
        }

        static public void setConexion()
        {
            frConfigura form;

            form = new frConfigura();
            form.ShowDialog();
            form.Dispose();
            form = null;
        }

        private void frConfigura_Load(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void label4_Click(object sender, EventArgs e)
        {

        }

        private void label5_Click(object sender, EventArgs e)
        {

        }

        private void bAceptar_Click(object sender, EventArgs e)
        {
            string nuevacadena;

            if (this.textBoxServidor.Text == "")
            {
                this.textBoxServidor.Text = "localhost";
            }

            if (this.textBoxPuerto.Text == "")
            {
                this.textBoxPuerto.Text = "3306";
            }

            if (this.textBoxUsuario.Text == "")
            {
                this.textBoxUsuario.Text = "guest";
            }

            nuevacadena = "Server=" + this.textBoxServidor.Text + ";Port=" + this.textBoxPuerto.Text + ";";
            nuevacadena += "Uid=" + this.textBoxUsuario.Text + ";Password=" + this.textBoxPassword.Text + ";";
            nuevacadena += "Pooling=True;";

            Conexion.SetCadenaDeConexion(nuevacadena);
            this.Close();
        }
    }
}
